#!/bin/bash

# CubeSLAM 双目实时SLAM启动脚本
# 使用方法: ./start_stereo_slam.sh [左摄像头ID] [右摄像头ID]

echo "=========================================="
echo "    CubeSLAM 双目实时SLAM启动脚本"
echo "=========================================="

# 检查参数
LEFT_CAMERA_ID=${1:-0}
RIGHT_CAMERA_ID=${2:-1}
echo "左摄像头ID: $LEFT_CAMERA_ID"
echo "右摄像头ID: $RIGHT_CAMERA_ID"

# 检查可执行文件是否存在
if [ ! -f "./Examples/bin/stereo_realtime" ]; then
    echo "错误: 找不到 stereo_realtime 可执行文件"
    echo "请先编译项目: cd build && make stereo_realtime"
    exit 1
fi

# 检查配置文件是否存在
if [ ! -f "./Examples/config/Stereo.yaml" ]; then
    echo "错误: 找不到配置文件 Stereo.yaml"
    exit 1
fi

# 检查词汇表文件是否存在
if [ ! -f "./Vocabulary/ORBvoc.txt" ]; then
    echo "错误: 找不到词汇表文件 ORBvoc.txt"
    exit 1
fi

echo "启动双目实时SLAM..."
echo "按 Ctrl+C 优雅退出"
echo "=========================================="

# 启动双目实时SLAM
./Examples/bin/stereo_realtime ./Vocabulary/ORBvoc.txt ./Examples/config/Stereo.yaml $LEFT_CAMERA_ID $RIGHT_CAMERA_ID

echo "双目实时SLAM已退出"
